#ifndef MemoryManagementUnit_h
#define MemoryManagementUnit_h

#include "Memory.h"
#include "resource.h"

class MemoryManagementUnit
{
public:
	MemoryManagementUnit(int numOfPRocesses, int numOfKernelPages, int numOfEnteries, int pageSize, Memory* MM);
	~MemoryManagementUnit(void);
	void contextSwitch(int pid);
	void addProcess(int pid);
	int getPage(int vAddr, int pTime);
	void replaceOuter(int pid, int page, int addr);
	int RequestedPage;
	int RequestDomain;
	void deleteProcess(int pid);
	bool freePage(int pageNum, int pid);

	void printTable();
	double getUserHitRate();
	double getKernelHitRate();	
private:
	int* m_currOuterTable;
	map<int, int*>* m_outerTables;
	int m_currProcessPid;
	int m_numOfPRocesses;
	int m_numOfKernelPages;
	int m_numOfEnteries;
	int m_pageSize;
	Memory* m_MM;
	
	int userMiss;
	int userTotal;
	int kernelMiss;
	int kernelTotal;
};

#endif
